package net.starwifi.duobao.interceptor;

import net.starwifi.duobao.service.WoService;
import net.starwifi.duobao.utils.WebUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 渠道标识拦截
 * Created by Administrator on 2015/11/25.
 */
public class ChannelInterceptor extends HandlerInterceptorAdapter {

    @Autowired
    WoService woService;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String cp=request.getParameter("cp");
        if(cp!=null&&!cp.equals("")){
             request.getSession().setAttribute("cp",cp);
             WebUtils.addCookieWithAge(request, response, "cp_id", cp);
        }
        return super.preHandle(request, response, handler);
    }



}
